package com.ting.etp.example.service;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ting.etp.example.mapper.TestTableMapper;
import com.ting.etp.example.mapper.TestTable;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Slf4j
public class HelloService {

    @Autowired
    TestTableMapper testTableMapper;


    @Transactional(rollbackFor = Exception.class)
    public String sayHello(String name) {
        TestTable testTable = new TestTable();
        testTable.setName("abc");
        testTableMapper.insert(testTable);
        List<TestTable> list = testTableMapper.selectList(new QueryWrapper<>());
        log.info("userList:{}", JSON.toJSONString(list));
        return "Hello, " + name + "!";
    }
} 